package it.uniroma2.structure.deploy;

public class Invoke {
	private final String partnerLinkAttr = "partnerLink";
	private String partnerLinkValue;
	private final String invokeTag = "invoke";
	private final String serviceTag = "service";
	private String serviceName;
	private String portName;
	
	public Invoke(String partnerLink, String namespace, String nameService, String port){
		this.partnerLinkValue = partnerLink;
		String temp = namespace.split("http://")[1];
		this.serviceName = temp + ":" + nameService;
		this.portName = port;
	}
	
	public String generateInvoke(){
		String output = "<" + this.invokeTag + " " + this.partnerLinkAttr + "=\"" + this.partnerLinkValue + "\">\n";
		
		output = output + "<" + this.serviceTag + " name=\"" + this.serviceName  + "\" port=\"" + this.portName  + "\"/>\n";
		
		output = output + "</" + this.invokeTag + ">\n";		
		return output;
	}
}
